// formPackage/pages/enterApply/enterApplyMain/enterApplyMain.js

import { globalSetting } from "../../../../service/config"

let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectArr: [
      // {
      //   title: "全民入驻",
      //   icon: "../../../img/qmrztag_icon.png",
      //   isChoose: false,
      //   navUrl: "/formPackage/pages/enterApply/fullNameApply/fullNameApply"
      // },
      // {
      //   title: "公司入驻",
      //   icon: "../../../img/companyenterright_icon.png",
      //   subTitle: "以公司身份入驻平台",
      //   isChoose: false,
      //   path: "/formPackage/pages/enterApply/companyApply/companyApply"
      // },
      // {
      //   title: "经纪人入驻",
      //   subTitle: "以经纪人身份入驻平台",
      //   icon: "https://saas.img.ylyc.top/icon/agencyenterright_icon.png",
      //   isChoose: false,
      //   path: "/formPackage/pages/enterApply/agentApply/agentApply"
      // },
      // {
      //   title: "置业顾问入驻",
      //   icon: "../../../img/zygwrztag_icon.png",
      //   isChoose: false,
      //   navUrl: "/formPackage/pages/enterApply/expertApply/expertApply"
      // }
    ],
    selectNavUrl: "",
    isLogin: false, // 是否登录页面跳转过来
    menuTop: app.globalData.menuButton.top,
    menuHeight: app.globalData.menuButton.height
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      isLogin: options.isLogin
    })
    //获取全局配置:
    this.queryGlobalSetting();
  },




  //获取全局配置:
  queryGlobalSetting() {
    wx.showLoading();
    globalSetting().then(res => {
      // console.log("JJLog:全局配置==:" + JSON.stringify(res));
      wx.hideLoading();
      if (res.code == 200) {
        this.setData({
          selectArr: res.data["17"] || []
        })
      }
    }).catch(err => {

      wx.hideLoading();
      wx.showToast({
        title: err || "查询失败",
        icon: "none"
      })
      console.log("JJLog:全局配置失败:" + JSON.stringify(err));
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
  },
  selectItemAction(e) {
    let path = e.currentTarget.dataset.path;
    wx.navigateTo({
      url: path,
    })
    // let index = e.currentTarget.dataset.index;
    // let arr = this.data.selectArr;
    // arr.forEach((i, idx) => {
    //   i.isChoose = false;
    //   if (idx == index) {
    //     i.isChoose = true
    //   }
    // })
    // this.setData({
    //   selectArr: arr,
    //   selectNavUrl: arr[index].navUrl
    // })
  },
  nextAction() {
    if (!this.data.selectNavUrl) {
      wx.showToast({
        title: '请选择您要入驻的角色',
        icon: "none"
      })
      return;
    }
    wx.navigateTo({
      url: this.data.selectNavUrl,
    })
  },

  jumpOver() {
    wx.switchTab({
      url: '/pages/home/home',
    })
  },



  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },



})